package thread;

import java.util.Scanner;

/*
 * @author zzr
 * @date: 2025/03/31  16:31
 * @description:
 */
public class ThreadDemo20 {
    private volatile static int flg = 0;
    public static void main(String[] args) {
        Thread t1 = new Thread(() -> {
            while(flg == 0) {
//                try {
//                    Thread.sleep(1);
//                } catch (InterruptedException e) {
//                    throw new RuntimeException(e);
//                }
            }
            System.out.println("t1 线程结束了");
        });
        Thread t2 = new Thread(() -> {
            System.out.println("请输入 flg 的值：");
            Scanner scanner = new Scanner(System.in);
            flg = scanner.nextInt();
        });

        t1.start();
        t2.start();
    }
}
